# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AndroidPublisher.V3.Model.SubscriptionOffer do
  @moduledoc """
  A single, temporary offer

  ## Attributes

  *   `basePlanId` (*type:* `String.t`, *default:* `nil`) - Required. Immutable. The ID of the base plan to which this offer is an extension.
  *   `offerId` (*type:* `String.t`, *default:* `nil`) - Required. Immutable. Unique ID of this subscription offer. Must be unique within the base plan.
  *   `offerTags` (*type:* `list(GoogleApi.AndroidPublisher.V3.Model.OfferTag.t)`, *default:* `nil`) - List of up to 20 custom tags specified for this offer, and returned to the app through the billing library.
  *   `otherRegionsConfig` (*type:* `GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferConfig.t`, *default:* `nil`) - The configuration for any new locations Play may launch in the future.
  *   `packageName` (*type:* `String.t`, *default:* `nil`) - Required. Immutable. The package name of the app the parent subscription belongs to.
  *   `phases` (*type:* `list(GoogleApi.AndroidPublisher.V3.Model.SubscriptionOfferPhase.t)`, *default:* `nil`) - Required. The phases of this subscription offer. Must contain at least one and at most two entries. Users will always receive all these phases in the specified order.
  *   `productId` (*type:* `String.t`, *default:* `nil`) - Required. Immutable. The ID of the parent subscription this offer belongs to.
  *   `regionalConfigs` (*type:* `list(GoogleApi.AndroidPublisher.V3.Model.RegionalSubscriptionOfferConfig.t)`, *default:* `nil`) - Required. The region-specific configuration of this offer. Must contain at least one entry.
  *   `state` (*type:* `String.t`, *default:* `nil`) - Output only. The current state of this offer. Can be changed using Activate and Deactivate actions. NB: the base plan state supersedes this state, so an active offer may not be available if the base plan is not active.
  *   `targeting` (*type:* `GoogleApi.AndroidPublisher.V3.Model.SubscriptionOfferTargeting.t`, *default:* `nil`) - The requirements that users need to fulfil to be eligible for this offer. Represents the requirements that Play will evaluate to decide whether an offer should be returned. Developers may further filter these offers themselves.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :basePlanId => String.t() | nil,
          :offerId => String.t() | nil,
          :offerTags => list(GoogleApi.AndroidPublisher.V3.Model.OfferTag.t()) | nil,
          :otherRegionsConfig =>
            GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferConfig.t() | nil,
          :packageName => String.t() | nil,
          :phases => list(GoogleApi.AndroidPublisher.V3.Model.SubscriptionOfferPhase.t()) | nil,
          :productId => String.t() | nil,
          :regionalConfigs =>
            list(GoogleApi.AndroidPublisher.V3.Model.RegionalSubscriptionOfferConfig.t()) | nil,
          :state => String.t() | nil,
          :targeting => GoogleApi.AndroidPublisher.V3.Model.SubscriptionOfferTargeting.t() | nil
        }

  field(:basePlanId)
  field(:offerId)
  field(:offerTags, as: GoogleApi.AndroidPublisher.V3.Model.OfferTag, type: :list)

  field(:otherRegionsConfig,
    as: GoogleApi.AndroidPublisher.V3.Model.OtherRegionsSubscriptionOfferConfig
  )

  field(:packageName)
  field(:phases, as: GoogleApi.AndroidPublisher.V3.Model.SubscriptionOfferPhase, type: :list)
  field(:productId)

  field(:regionalConfigs,
    as: GoogleApi.AndroidPublisher.V3.Model.RegionalSubscriptionOfferConfig,
    type: :list
  )

  field(:state)
  field(:targeting, as: GoogleApi.AndroidPublisher.V3.Model.SubscriptionOfferTargeting)
end

defimpl Poison.Decoder, for: GoogleApi.AndroidPublisher.V3.Model.SubscriptionOffer do
  def decode(value, options) do
    GoogleApi.AndroidPublisher.V3.Model.SubscriptionOffer.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AndroidPublisher.V3.Model.SubscriptionOffer do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
